package com.udf.flink.demo.stream.state;

import org.rocksdb.RocksDB;
import org.rocksdb.RocksDBException;
import org.rocksdb.RocksIterator;

/**
 * @author fanrui03
 * @time 2020-05-24 14:49:45
 */
public class RocksDBDemo {

    private static byte[] KEY = "key".getBytes();
    private static String ROCKSDB_DIR = "d:/home/db";
    private static String ROCKSDB_CHECKPOINT_DIR = "/Users/fanrui03/Documents/tmp/rocksdb1";

    public static void main(String[] args) throws RocksDBException {

        RocksDB db = RocksDB.open(ROCKSDB_DIR);
//        db.compactRange();
        RocksIterator iter = db.newIterator();
        for (iter.seekToFirst();iter.isValid();iter.next()) {
            System.out.println("iter key: " + new String(iter.key()) + ",iter value: " +
                    new String(iter.value()));
        }
//        db.put(KEY, "value".getBytes());
//        System.out.println(new String(db.get(KEY)));

//        Checkpoint checkpoint = Checkpoint.create(db);
//        checkpoint.createCheckpoint(ROCKSDB_CHECKPOINT_DIR);


    }

}